"use strict";

(function () {
  function r(e, n, t) {
    function o(i, f) {
      if (!n[i]) {
        if (!e[i]) {
          var c = "function" == typeof require && require;
          if (!f && c) return c(i, !0);
          if (u) return u(i, !0);
          var a = new Error("Cannot find module '" + i + "'");
          throw a.code = "MODULE_NOT_FOUND", a;
        }

        var p = n[i] = {
          exports: {}
        };
        e[i][0].call(p.exports, function (r) {
          var n = e[i][1][r];
          return o(n || r);
        }, p, p.exports, r, e, n, t);
      }

      return n[i].exports;
    }

    for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
      o(t[i]);
    }

    return o;
  }

  return r;
})()({
  1: [function (require, module, exports) {
    "use strict";

    loader.define({
      depend: ['pages/config/config'],
      loaded: function loaded(config, require, exports, module, global) {
        this.pageview = {};

        this.pageview.init = function () {
          // var data;
          // var getParams = bui.getPageParams();
          //     getParams.done(function(result){
          //         data=result['data'];
          //     })
          var data;
          var getParams = bui.getPageParams();
          getParams.done(function (result) {
            console.log(result);
            data = result['data'];
          });
          $("#sure").on("click", function (e) {
            var phone = $("#userphone").attr("value");

            if (phone == '') {
              bui.hint("手机号不能为空");
              return;
            }

            var data_ = {
              phone: phone
            };
            data_ = JSON.stringify(data_);
            bui.ajax({
              url: config.apiurl + "api/v1.0/nameforphone",
              data: data_,
              //接口请求的参数
              // 可选参数
              method: "POST",
              headers: {
                'Content-Type': 'application/json'
              }
            }).then(function (result) {
              // 成功
              if (result.ans == 1) {
                bui.hint("该手机号不存在");
              } else if (result.ans == 0) {
                var msg = result.name;
                var dialog = bui.dialog();
                var dialogobj = dialog.create({
                  title: "绑定",
                  content: "请问您的昵称是" + msg + "吗?",
                  buttons: [{
                    name: "确定",
                    value: "makeSure"
                  }, {
                    name: "取消",
                    value: "close"
                  }],
                  callback: function callback(e) {
                    var id = $(e.target).attr("value");

                    if (id == "makeSure") {
                      data = {
                        phone: phone,
                        openid: data.openid
                      };
                      data = JSON.stringify(data);
                      bui.ajax({
                        url: config.apiurl + "api/v1.0/phoneforold",
                        data: data,
                        //接口请求的参数
                        // 可选参数
                        method: "POST",
                        headers: {
                          'Content-Type': 'application/json'
                        }
                      }).then(function (result) {
                        // 成功
                        if (result.ans == 1) //此处1表示插入成功，且用户信息是完整的，2表示插入成功，但用户信息不完整
                          {
                            bui.hint("登录成功");
                            bui.load({
                              url: "pages/success/success"
                            });
                          } else if (result.ans == 2) {
                          bui.hint("个人信息填写不完整，现为您转到信息填写界面");
                          var personlocation = "";
                          bui.load({
                            url: "pages/registercontent/registercontent",
                            param: {
                              flag: "1",
                              personlocation: personlocation
                            }
                          });
                        } else bui.hint("手机号不存在");
                      }, function (result, status) {
                        // 失败 console.log(status)
                        bui.hint("插入失败");
                      });
                    }
                  }
                });
                dialogobj.open();
              }
            }, function (result, status) {
              // 失败 console.log(status)
              bui.hint("获取内容失败");
            });
          });
        };

        this.pageview.init();
        return this.pageview;
      }
    });
  }, {}]
}, {}, [1]);